package com.example.demo.controller;


import com.example.demo.entity.Status;
import com.example.demo.mapper.IdeaMapper;
import com.example.demo.mapper.StatusMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class StatusController {

    @Autowired
    private IdeaMapper ideaMapper;

    @Autowired
    private StatusMapper statusMapper;
    //点赞说说并更改数据
    @RequestMapping("/updatatumbupnumber")
    public boolean updatatumbupnumber(int ideaid,String openid,int tumbupnumber){

        System.out.println(ideaid+" xxxx "+openid+ "sssss"+tumbupnumber);

        Status status=new Status();
        status.setIdeaid(ideaid);
        status.setOpenid(openid);
        status.setStatus('a');
        int ideanum=ideaMapper.updatacomment(tumbupnumber,ideaid);
        int statusnum=statusMapper.InsetsStatus(status);

        return true;
    }


    //取消点赞
    @RequestMapping("/delectnumber")
    public boolean delectnumber(int ideaid,String openid,int tumbupnumber){
        Status status=new Status();
        status.setIdeaid(ideaid);
        status.setOpenid(openid);
        status.setStatus('a');
        int ideanum=ideaMapper.updatacomment(tumbupnumber,ideaid);
        int delete=statusMapper.deleteStatus(ideaid,openid);
        return true;
    }

}
